﻿using AlarmModule.DbContexts;
using AlarmModule.Interface.Implementation;
using AlarmModule.ViewModels;
using AlarmModule.Views;
using Microsoft.EntityFrameworkCore;
using Prism.Ioc;
using Prism.Modularity;

namespace AlarmModule {
    public class AlarmProfile : IModule {
        public void OnInitialized(IContainerProvider containerProvider) {

        }

        public void RegisterTypes(IContainerRegistry containerRegistry) {
            containerRegistry.RegisterForNavigation<AlarmView,AlarmViewModel>();
            // 注册DbContext
            containerRegistry.RegisterScoped<AlarmDbContext>(provider => {
                var optionsBuilder = new DbContextOptionsBuilder<AlarmDbContext>();
                optionsBuilder.UseSqlite("Data Source=D:\\Projects\\sqlite\\alarm.db;");
                return new AlarmDbContext(optionsBuilder.Options);
            });

            // 重要：确保 LogAlarmNotifier 也注册为 Scoped
            containerRegistry.RegisterScoped<LogAlarmNotifier>();


        }
    }
}